//
//  EventTrackingAPI.swift
//  EventTracking
//
//  Created by 孙长坦 on 2022/11/29.
//

import Foundation
import Moya
import LibNetwork

enum EventTrackingAPI {
    case log(data: [[String: Any]])
}

extension EventTrackingAPI: APITargetType {
    var path: String {
        switch self {
        case .log:
            return "/environment/user-center/user/log/v2/upload"
        }
    }
    
    var method: Moya.Method {
        switch self {
        case .log:
            return .post
        }
    }
    
    var customizeHeaders: [String: String]? {
        switch self {
        case .log:
            return ["Content-Type": "application/json"]
        }
    }
    
    var task: Moya.Task {
        switch self {
        case .log(let data):
            return .requestData(try! JSONSerialization.data(withJSONObject: data, options: .prettyPrinted))
        }
    }
}
